def check(a):
    mapping = {")":"(","}":"{","]":"[",">":"<"}
    stack = []
    for i in a:
        if i in mapping:
            element = stack.pop() if stack else "#"
            if mapping[i] != element:
                return False
        elif i not in mapping:
            pass
        else:
            stack.append(i)
    return not stack
print(check(input()))
      
        
